<?php
/**
 * Created by PhpStorm.
 * User: fengchen
 * Date: 2019/8/16
 * Time: 上午9:40
 */

namespace App\Http\Middleware;

use Illuminate\Support\Str;

class TelescopeAuth
{
    /**
     * Handle the incoming request.
     *
     * @param  \Illuminate\Http\Request $request
     * @param  \Closure                 $next
     * @return \Illuminate\Http\Response
     */
    public function handle($request, $next)
    {
        $allowIp = [
            '45.117.97.64',
            '61.61.134.118',
            '127.0.0.1'
        ];

        abort_if(!in_array(ip(), $allowIp) && !Str::startsWith(ip(), '192.168.'), 403);

        return $next($request);
    }
}
